package com.aqie.easy.string;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * 1078. Bigram 分词
 */
public class FindOcurrences {
    public static String[] findOcurrences(String text, String first, String second) {
        ArrayList<String> ans = new ArrayList<>();
        String[] split = text.split("\\s");
        for (int i = 0; i < split.length-2;i ++){
            if (split[i].equals(first) && split[i+1].equals(second)){
                ans.add(split[i+2]);
            }
        }
        return ans.toArray(new String[0]);
    }

    public static void main(String[] args) {
        String str = "alice is a good girl she is a good student";
        String first = "a", second = "good";
        System.out.println(Arrays.toString(findOcurrences(str,first,second)));
    }
}
